﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DARE
{
    public class CCursorData: ISaveData<CCursor, CCursor>
    {
        public Rectangle rect;
        public Vector2 size;
        public CHudTextureData texture;
        public Dictionary<string, CHudTextureData> textures;

        public void FillDataStructure(CCursor c)
        {
            rect = c.Rectangle;
            size = c.Size;
            texture = new CHudTextureData();
            texture.FillDataStructure(c.Texture);
            textures = new Dictionary<string, CHudTextureData>();
            foreach (KeyValuePair<string, CHudTexture> t in c.Textures)
            {
                CHudTextureData htd = new CHudTextureData();
                htd.FillDataStructure(t.Value);
                textures.Add(t.Key, htd);
            }
        }

        public virtual void FillFromDataStructure(CCursor cursor)
        {
            cursor.Rectangle = rect;
            cursor.Size = size;
            CHudTexture tex = new CHudTexture();
            texture.FillFromDataStructure(tex);
            cursor.Texture = tex;
            cursor.Textures.Clear();
            foreach (KeyValuePair<string, CHudTextureData> t in textures)
            {
                CHudTexture text = new CHudTexture();
                t.Value.FillFromDataStructure(text);
                cursor.Textures.Add(t.Key, text);
            }
        }
    }
}
